﻿using System;

namespace MultiConvert
{
    public class MultiConvertParameters
    {
        
        private String fromFileName;
        private String toFileName;
        public String ConvertMethod { get; set; }
        public Boolean GetHelp { get; set; }

        private String CurDir = System.Environment.CurrentDirectory;
        private char[] Separator = { '=' };
        private string[] SubPhrase;

        public MultiConvertParameters(string[] args)
        {
            this.GetHelp = false;
            for (int i = 0; i < args.Length; i++)
            {
                char[] TrimmChar = { ' ' };
                SubPhrase = args[i].Split(Separator, 2);
                switch (SubPhrase[0])
                {
                    case "FromFileName":
                        this.fromFileName = SubPhrase[1].Trim(TrimmChar);
                        break;

                    case "ToFileName":
                        this.toFileName = SubPhrase[1].Trim(TrimmChar);
                        break;

                    case "ConvertMethod":
                        this.ConvertMethod = SubPhrase[1].Trim(TrimmChar);
                        break;
                   
                    case "help":
                        this.GetHelp = true;
                        break;

                    case "--help":
                        this.GetHelp = true;
                        break;

                    case "-h":
                        this.GetHelp = true;
                        break;                    

                    default:
                        break;
                }
            }
        }

        public String FromFile
        {
            get
            {                
                if (FromDirectory.Length == 0 ) return CurDir + "\\" + this.fromFileName;
                else return this.fromFileName;
            }
        }

        public String FromExtension
        {
            get
            {
                return System.IO.Path.GetExtension(this.fromFileName);                
            }
        }

        public String FromDirectory
        {
            get
            {
                return System.IO.Path.GetDirectoryName(this.fromFileName);
			}
        }

        public String ToFile
        {
            get
            {                
                if (ToDirectory.Length == 0) return CurDir + "\\" + this.toFileName;
                else return this.toFileName;
            }
        }

        public String ToDirectory
        {
            get
            {
                return System.IO.Path.GetDirectoryName(this.toFileName);
            }             
        }

    }
}

